#ifndef TEST_MANAGER__
#define TEST_MANAGER__

#include <iostream>

#include "base.h"
#include "options.h"
#include "options_coords.h"
#include "options_philadelphia.h"
#include "options_genetic.h"
#include "options_sequential.h"
#include "options_annealing.h"
#include "options_tabu.h"
#include "algorithm.h"
#include "algorithm_genetic.h"
#include "algorithm_permutation.h"
#include "algorithm_sequential.h"
#include "algorithm_annealing.h"
#include "algorithm_tabu.h"
#include "area.h"
#include "area_coords.h"
#include "area_philadelphia.h"
#include "history.h"

#include "ticpp/ticpp.h"

/** Trida rozdelujici vsechnu praci v programu. Stara se o otevreni a nacitani
 * vstupniho souboru, vytvareni map a algoritmu se spravnym nastavenim. Dale
 * spousti algoritmy na vytvorenych mapach a spoctene vysledky zaznamenava do historie.
 * Dale vytvari zakladni nastaveni programu, jimz je zprostredkovan vystup do spravnych
 * vystupnich souboru.
 */
class TestManager {
public:
	TestManager(const char * settings, ProgressDisplayer * displayer = NULL);
	~TestManager();
	void SolveTests();
	void PrintResults();
	static Algorithm * GetAlgorithm(ticpp::Element * algorithmNode, Options * base);
	static Area * GetArea(ticpp::Element * mapNode, Options * base);

	Options * base; ///< zakladni nastaveni programu
private:
	bool OpenFile(std::ostream ** file, const std::string & name);
	void CloseFiles(std::ostream * gout, std::ostream * glog);
	void PrintTestOutputHeader(const std::string & testName);
	void PrintTestLogHeader(const std::string & testName);
	void PrintTestHeader(const std::string & testName);
	void PrintAlgorithmHeader(Algorithm * algorithm);
	void PrintAreaHeader(Area * area);
	void SaveResults(Algorithm * al);
	int CountTests();
	ticpp::Document document; ///< vstupni XML dokument
	History history; ///< historie vysledku
	int round; ///< cislo aktualne zpracovavaneho testu
	bool error; ///< informace o tom, zda nastala pri otevirani vstupniho souboru chyba
	std::ostream * out_, ///< hlavni vystupni stream
		* log_; ///< vystupni logovaci stream
};

#endif
